package chapter05;

import java.util.List;
import java.util.concurrent.TimeoutException;

/**
 * @author chisheng
 * @since 2021-11-07
 */
public interface Lock {

    /**
     * 永远阻塞线程
     *
     * @throws InterruptedException 中断异常
     */
    void lock() throws InterruptedException;

    /**
     * 阻塞线程指定时长
     *
     * @param millis 阻塞时长
     * @throws InterruptedException 中断异常
     * @throws TimeoutException     超时异常
     */
    void lock(long millis) throws InterruptedException, TimeoutException;

    /**
     * 释放线程锁
     */
    void unlock();

    /**
     * 获取被阻塞线程队列
     *
     * @return 线程队列
     */
    List<Thread> getBlockedThreads();

}
